cmake_minimum_required(VERSION 3.15)
project(thrift_tutorial_c C)

set(CMAKE_C_STANDARD 99)



#add_executable(thrift_tutorial_c c_glib_server.c hello.c gtk_test.c)



#include_directories(SYSTEM "${Boost_INCLUDE_DIRS}")

#Make sure gen-c_glib files can be included

aux_source_directory(./gen-c_glib DIR_SRC)

include_directories("${CMAKE_CURRENT_BINARY_DIR}")

include_directories("${CMAKE_CURRENT_BINARY_DIR}/gen-cpp" "${CMAKE_CURRENT_BINARY_DIR}/gen-c_glib")

include_directories("${PROJECT_SOURCE_DIR}/lib/cpp/src")

include_directories("./gen-c_glib")
include_directories("/usr/local/Cellar/glib/2.64.1/include/glib-2.0")
include_directories("/usr/local/Cellar/glib/2.64.1/lib/glib-2.0/include")

include_directories("/Users/wolingzong/thrift/lib/c_glib/src")
include_directories("/Users/wolingzong/thrift/lib/c_glib/src/thrift")


include_directories("/Users/wolingzong/CLionProjects/thrift_tutorial_c/")
# 所需要的glibc(gtk)库文件的目录
include_directories(
        /usr/include/glib-2.0
        /usr/lib/x86_64-linux-gnu/glib-2.0/include
)



set(tutorialgencpp_SOURCES
        /Users/wolingzong/CLionProjects/thrift_tutorial_c/gen-c_glib/calculator.c
        /Users/wolingzong/CLionProjects/thrift_tutorial_c/gen-c_glib/calculator.h
        /Users/wolingzong/CLionProjects/thrift_tutorial_c/gen-c_glib/shared_service.c
        /Users/wolingzong/CLionProjects/thrift_tutorial_c/gen-c_glib/shared_service.h

        /Users/wolingzong/CLionProjects/thrift_tutorial_c/gen-c_glib/shared_types.c
        /Users/wolingzong/CLionProjects/thrift_tutorial_c/gen-c_glib/shared_types.h

        /Users/wolingzong/CLionProjects/thrift_tutorial_c/gen-c_glib/tutorial_types.c
        /Users/wolingzong/CLionProjects/thrift_tutorial_c/gen-c_glib/tutorial_types.h
        /Users/wolingzong/CLionProjects/thrift_tutorial_c/c_glib_client.c)




add_library(tutorialgencpp STATIC ${tutorialgencpp_SOURCES} )
target_link_libraries(tutorialgencpp thrift )

add_custom_command(OUTPUT gen-c_glib/calculator.c gen-c_glib/calculator.h gen-c_glib/shared_service.c  gen-c_glib/shared_service.h gen-c_glib/shared_types.c  gen-c_glib/shared_types.h gen-c_glib/tutorial_types.c gen-c_glib/tutorial_types.h
        COMMAND ${THRIFT_COMPILER} --gen cpp -r ${PROJECT_SOURCE_DIR}/tutorial/tutorial.thrift
        )



add_executable(TutorialServer server/c_glib_server.c ${DIR_SRC})
target_link_libraries(TutorialServer tutorialgencpp -lthrift_c_glib -lgobject-2.0)
if (ZLIB_FOUND)
    target_link_libraries(TutorialServer ${ZLIB_LIBRARIES} )

add_executable(TutorialClient client/c_glib_client.c)
target_link_libraries(TutorialClient tutorialgencpp)
if (ZLIB_FOUND)
    target_link_libraries(TutorialClient ${ZLIB_LIBRARIES})
endif ()
endif ()











